<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/fileupload.js"></script>
    <script src="My97DatePicker/WdatePicker.js"></script>
    <script src="bootstrap-4.6.0-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="bootstrap-4.6.0-dist/css/bootstrap.min.css">
</head>
<body>
<div class="row">
    <div class="col-sm-2">
        <jsp:include page="/layout/left1.jsp"></jsp:include>
    </div>
    <div class="col-sm-10">

        <input type="text" hidden id="aaa" value="${shouhuo.shouhuoid}">
        <form>
            物料编号: <input type="text"name="wid" readonly id="wid"><br>
            物料名称: <input type="text"name="wname" readonly id="wname"><br>
            市场价: <input type="text"name="price" readonly id="price"><br>
            被替换数量: <input type="text"name="num"  id="num"><br>
            金额: <input type="text" name="pricces" readonly id="prices"><br>
        </form>
        <hr>
        <form>
            物料编号: <input type="text"name="tid"id="tid" readonly><br>
            物料名称: <input type="text"name="tname"id="tname" readonly><br>
            市场价: <input type="text"name="tprice"id="tprice" readonly><br>
            替换数量: <input type="text"name="tnum"id="tnum" ><br>
            金额: <input type="text" name="pricces" readonly id="prices2"><br>
        </form>

        <button id="bc">保存</button>
    </div>
</div>
</body>
<script>
    let val = $("#aaa").val();
    $.ajax({
        url:"findsnn.do",
        data:{"snow":val},
        dataType:"json",
        type:"post",
        success:function (a) {
            $("#wid").val(a[0].wid);
            $("#wname").val(a[0].wname);
            $("#price").val(a[0].price);

            $("#beizhu").val(a[0].beizhu);

        }
    })

    $("#num").blur(function () {
        var ii = $(this).val();
        alert(ii)
        var val1 = $("#price").val();
        $("#prices").val(val1*ii)
    })

    $.ajax({
        url:"findalltidai.do",
        dataType:"json",
        type:"post",
        success:function (a) {
            $("#tid").val(a[0].wid);
            $("#tname").val(a[0].tname);
            $("#tprice").val(a[0].tprice);

        }
    })
    $("#tnum").blur(function () {
        var ii = $(this).val();
        alert(ii)
        var val1 = $("#tprice").val();
        $("#prices2").val(val1*ii)
    })


    $("#bc").click(function () {
        var val2 = $("#prices").val();
        alert(val2)
        if(val2==null){
            alert("金额为空");
        }
        location="list.do"
    })
</script>
</html>
